package com.chaosj.memory.handlers;

import java.util.HashSet;
import java.util.Set;

/**
 * @className: DisorderNumberHandler
 * @description:
 * @author: caoyangjie
 * @date: 2021/8/15
 **/
public class DisorderNumberHandler extends AbstractToolHandler<String>{
    @Override
    public String name() {
        return "number";
    }

    @Override
    public void handler(String count, StringBuffer outBuffer) {
        Set<Integer> has = new HashSet<>();
        Integer val = 0;
        Integer index = Integer.valueOf(count);
        for (int i = 1; i <= index; i ++) {
            do{
                val = next.nextInt(110);
            } while ( has.contains(val) );
            has.add(val);
            val+=1;
            outBuffer.append(val>100?"0"+(val-100):(val<10?" "+val:val)).append((i>1&&i%10==0)?" \n":" ");
        }
    }

    @Override
    public String cmd2Dto(String[] args) {
        return args.length>1? args[1]: "20";
    }
}
